package com.jie.study

import android.graphics.Color
import android.widget.TextView
import androidx.cardview.widget.CardView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.jie.study.bean.MainBean

/**
 * 主界面适配器
 * @author jie
 */
class MainAdapter(data: MutableList<MainBean>)
    : BaseQuickAdapter<MainBean, BaseViewHolder>(R.layout.adapter_main, data) {

    override fun convert(holder: BaseViewHolder, item: MainBean) {
        val cvContent = holder.getView(R.id.cvContent) as CardView
        val tvContent = holder.getView(R.id.tvContent) as TextView
        val position = data.indexOf(item)
        val color = (125 - position * 5) * itemCount + 125
        cvContent.setCardBackgroundColor(Color.rgb(255, color, 0))
        tvContent.text = item.title
    }
}